from proxy.proxy_service import ProxyService
from model.proxy import Proxy, ProxyType
from model.error import ParkSpiderError, ParkSpiderErrorCode

tunnel_proxy_host = "tun-yowmaw.qg.net"  # 隧道代理的地址
tunnel_proxy_port = "15404"  # 隧道代理的地址
tunnel_auth_key = "5264D476"  # 隧道代理的AuthKey
tunnel_auth_password = "79AC3451AFEA"  # 隧道代理的AuthPwd


class TunnelProxyService_QG(ProxyService):
    def take(self, platformId: int) -> Proxy:
        try:
            # 账密模式
            meta = f"http://{tunnel_auth_key}:{tunnel_auth_password}@{tunnel_proxy_host}:{tunnel_proxy_port}"
            return Proxy(meta, ProxyType.Tunnel)
        except Exception as e:
            raise ParkSpiderError(ParkSpiderErrorCode.ProxyFail, repr(e))
